#include<iostream>
#include<vector>
using namespace std;
typedef int age;//age赋值为int的同义词


class A
{
public:
	

	void bb()
	{
		cout<<"ahello"<<endl;

	}
	
	
};

class B: public A
{
public:
	void bb()
	{
		cout<<"bhello"<<endl;

	}

	
};

class Base
{
public:
virtual void f(float x){ cout << "Base::f(float) " << x << endl; }
void g(float x){ cout << "Base::g(float) " << x << endl; }
void h(float x){ cout << "Base::h(float) " << x << endl; }
};
 
class Derived : public Base
{
public:
virtual void f(float x){ cout << "Derived::f(float) " << x << endl; }//virtual用在这里使得基类得到了派生类的函数。
void g(int x){ cout << "Derived::g(int) " << x << endl; }
void h(float x){ cout << "Derived::h(float) " << x << endl; }
};


int main(void)
{

	Base base;
	base.f(2);
	base.g(2);
	base.h(2);

	Derived derived;
	derived.f(2);
	derived.g(2.0);
	derived.h(2);
	derived.Base::f(2);
	derived.Base::g(2.0);
	derived.Base::h(2);

	Base *pbase = new Derived;// Base *p = &derived
	pbase->f(2); //virtual 将父函数覆盖了
	pbase->g(2.1);
	pbase->h(2);

	//Derived *pderived = new Base;//invalid conversion from 'Base*' to 'Derived*'
	


















	A a;
	a.bb();
	A *c;
	c->bb();
	B b;
	b.bb();
	b.A::bb();//调用父类的函数


	vector<int> vecMyHouse(100); //等于 int myHouse[100]
	vecMyHouse[50] = 1024;
	vecMyHouse.resize(400);//改变容器大小


	std::vector<int>::iterator p;
	p = vecMyHouse.begin();
	*p = 20;
	cout<<*p<<'\t'<<vecMyHouse[0]<<endl;


	int i(1024);
	int *pp = &i;
	cout<<*pp<<' '<<i<<' '<<pp<<' '<<&i<<endl;
	int *pi = new int(1024);
	cout<<*pi<<' '<<i<<' '<<pi<<' '<<&i<<endl;
	delete pi;





	age Tom = 11;
	cout<<Tom<<endl;
	string s1; //字符串中间不能有空格否则只能输出第一个空格之前的
	cin>>s1;
	cout<<s1<<endl;

	return 0;
}
